{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <!-- Panel Other -->
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>用户列表</h5>
        </div>
        <div class="ibox-content">
            <!--搜索框开始-->
            <div class="row">
                <div class="col-sm-12">
                    <div class="col-sm-2" style="width: 100px">
                        <div class="input-group">
                            <a href="{:url('userAdd')}">
                                <button class="btn btn-outline btn-primary" type="button">添加用户</button>
                            </a>
                        </div>
                    </div>
                    <form name="admin_list_sea" class="form-search" method="post" action="{:url('index')}">
                        <div class="col-sm-3">
                            <div class="input-group">
                                <input type="text" id="key" class="form-control" name="key" value=""
                                       placeholder="输入需查询的用户名"/>
                                <span class="input-group-btn"> 
                                    <button type="submit" class="btn btn-primary"><i
                                            class="fa fa-search"></i> 搜索</button>
                                </span>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
            <!--搜索框结束-->

            <div class="example-wrap">
                <div class="example">
                    <table class="layui-table"
                           lay-data="{id:'user',height:'full-210',url:'index',method:'post',page:true,limit:10}"
                           lay-filter="user">
                        <thead>
                        <tr>
                            <th lay-data="{field:'id',title:'ID',fixed:true,width:60,align:'center'}"></th>
                            <th lay-data="{field:'username',title:'管理员名称',width:150}"></th>
                            <th lay-data="{field:'title',title:'管理员角色',width:120}"></th>
                            <th lay-data="{field:'portrait',templet:'#portrait',title:'头像',width:80,align:'center'}"></th>
                            <th lay-data="{field:'real_name',title:'真实姓名',width:100}"></th>
                            <th lay-data="{field:'status',title:'状态',width:120,align:'center',templet:'#status'}"></th>
                            <th lay-data="{field:'loginnum',title:'登录次数',width:120,align:'center',sort:true}"></th>
                            <th lay-data="{field:'last_login_ip',title:'上次登录ip',width:150}"></th>
                            <th lay-data="{field:'last_login_time',title:'上次登录时间',width:180}"></th>
                            <th lay-data="{title:'操作',width:130,toolbar:'#action',align:'center',fixed:'right'}"></th>
                        </tr>
                        </thead>
                    </table>
                    <script type="text/html" id="portrait">
                        <img src="/static/uploads/face/{{d.portrait}}" class="img-circle" style="height:28px"
                             onerror="this.src='/static/admin/images/head_default.gif'"/>
                    </script>
                    <script type="text/html" id="status">
                        <input type="checkbox" name="status" value="{{d.id}}" lay-skin="switch" lay-text="开启|关闭"
                               lay-filter="status" {{d.status==1?'checked':''}}>
                    </script>
                    <script type="text/html" id="action">
                        {{# if(d.id!==1){ }}
                        <div class="layui-btn-group">
                            <a href="javascript:;" onclick="userEdit({{d.id}})"
                               class="layui-btn layui-btn-normal layui-btn-xs">
                                <i class="fa fa-paste"></i> 编辑</a>&nbsp;&nbsp;
                            <a href="javascript:;" onclick="userDel({{d.id}})"
                               class="layui-btn layui-btn-danger layui-btn-xs">
                                <i class="fa fa-trash-o"></i> 删除</a>
                            {{# } }}
                        </div>
                    </script>
                </div>
            </div>
            <!-- End Example Pagination -->
        </div>
    </div>
</div>
<!-- End Panel Other -->
</div>

<!-- 加载动画 -->
<div class="spiner-example">
    <div class="sk-spinner sk-spinner-three-bounce">
        <div class="sk-bounce1"></div>
        <div class="sk-bounce2"></div>
        <div class="sk-bounce3"></div>
    </div>
</div>

{include file="public/footer" /}

<script type="text/javascript">
    $(".spiner-example").css('display', 'none'); //数据加载完关闭动画
    var form = layui.form;

    //编辑用户
    function userEdit(id) {
        location.href = './userEdit/id/' + id + '.html';
    }

    //删除用户
    function userDel(id) {
        lunhui.confirm(id, '{:url("userDel")}');
    }

    /**
     * 热门状态
     */
    form.on('switch(status)', function (obj) {
        $.post("{:url('user_state')}", {id: this.value}, function (result) {
            //     //layer.tips(result.msg, obj.othis, {tips: 4});
        });
    });

</script>
</body>
</html>